<?php
namespace Home\Controller;
use Think\Controller;
class SystemConfigController extends CommonController {
    public function operation(){
        $systemConfig_model = M("SystemConfig");
        
        /* 系统设置 项 */
        $sysconfig_type = $_GET['sysconfig_type'];
        if($sysconfig_type==null||$sysconfig_type==null){
            $sysconfig_type = $_POST['sysconfig_type'];
        }
        $sysconfig = C('sysconfig');
        $id = $sysconfig[$sysconfig_type];
        $condition['sc_id'] = $id;
        if(IS_POST){
            $data['sc_value'] = $_POST["sc_value"];
            if($_POST["sc_value_2"]!=null){
                $data['sc_value_2'] = $_POST["sc_value_2"];
            }
            $result = $systemConfig_model->where($condition)->save($data);
            if($sysconfig_type=='msg'){
                M("User")->where(array('us_is_readed'=>1))->save(array('us_is_readed'=>0));
            }
            if($result){
                exit(success('成功！',false));
            }else{
                exit(error('失败！'));
            }
        }else{
            $this->assign("sysconfig_type",$sysconfig_type);
            $data = $systemConfig_model->where($condition)->find();
            $this->assign("data",$data);
            $this->display();
        }

    }
}